/**
 * 渠道主相关api
 */
angular.module('imsApp').factory('ChannelsManager', ['$http','api', 'paramsManager', function ($http, api, paramsManager) {
    var ChannelsManager = {
        /**
         * 渠道主列表
         params:[pageNo,pageSize] {status,keyword}
         */
        channelsList: function (params, query) {
            return $http.get(api+'/ims/channels/'+paramsManager.params(params)+paramsManager.query(query)).then(function (result) {
                return result;
            });
        },
        /**
         * 渠道主添加
         * @param params
         * @returns
         */
        channelsAdd: function (params) {
            return $http.post(api+'/ims/channels', params).then(function (result) {
                return result;
            });
        },
        /**
         * 渠道主详情
         * @param channelId
         * @returns
         */
        channelsDetail: function (channelId) {
            return $http.get(api+'/ims/channels/'+channelId).then(function (result) {
                return result;
            });
        },
        /**
         *渠道主删除
         * @param creativeId
         */
        channelsDelete: function (ids) {
            return $http.delete(api+'/ims/channels/'+ids.join(",")).then(function (result) {
                return result;
            });
        },
        /**
         *渠道主修改
         * @param
         */
        channelsEdit: function (channelId,params) {
            return $http.put(api+'/ims/channels/'+channelId,params).then(function (result) {
                return result;
            });
        },
        /**
         *渠道主统计
         * @param params [channelId,pageNo,pageSize]
         * @returns
         */
        channelsStats: function (params,query) {
            return $http.get(api+'/ims/channels/'+paramsManager.params(params)+paramsManager.query(query)).then(function (result) {
                return result;
            });
        },
        /**
         *渠道主修改状态
         * @param params {disabled:}
         * @returns
         */
        channelsStatusEdit: function (channelId,params) {
            return $http.put(api+'/ims/channels/'+channelId+'/status',params).then(function (result) {
                return result;
            });
        },
        /**
         *重置渠道主密码
         * @param params {disabled:}
         * @returns
         */
        channelsReset: function (channelId,params) {
            return $http.put(api+'/ims/channels/'+channelId+'/password',params).then(function (result) {
                return result;
            });
        },
       /**
         *检查渠道主是否重名
         * @param params
         * @returns
         */
        channelsCheckShortName: function (shortName) {
            return $http.post(api+'/ims/channels/checkShortName',{shortName:shortName}).then(function (result) {
                return result;
            });
        },
        /**
         *检查渠道主是否重名
         * @param params
         * @returns
         */
        channelsCheckUsername: function (params) {
            return $http.post(api+'/ims/channels/checkUsername',params).then(function (result) {
                return result;
            });
        },

    };


    return ChannelsManager;
}]);
